{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
	<div class="content">
        <!-- form start -->
        <form class="am-form form-validation" action="{{:MyUrl('admin/role/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/role/index', $params)}}">
        	<legend>
				<span class="am-text-default">角色{{if empty($data['id'])}}添加{{else /}}编辑{{/if}}</span>
				<a href="{{:MyUrl('admin/role/index', $params)}}" class="am-fr am-text-sm am-margin-top-sm am-icon-mail-reply"> 返回</a>
			</legend>
        	<div class="am-form-group">
				<label>角色名称</label>
				<input type="text" placeholder="角色名称" name="name" minlength="2" maxlength="16" data-validation-message="角色名称格式 2~8 个字符之间" class="am-radius" {{if !empty($data)}}value="{{$data.name}}"{{/if}} required />
			</div>
			
			<div class="am-form-group">
				<label>菜单权限</label>
				<ul class="tree-list am-avg-sm-1 am-avg-md-1 am-avg-lg-1">
					{{if !empty($power['power'])}}
						{{foreach $power.power as $v}}
							<li>
								<div class="item-content am-padding-sm am-margin-bottom-xs am-margin-right-xs {{if $v['is_show'] eq 0}}bk-cr-ffd{{/if}}">
									<label>
										<input type="checkbox" name="power_id" value="{{$v.id}}" class="node-choice" {{if $v['is_power'] eq 'ok'}}checked{{/if}} />
										<span>{{$v.name}}</span>
									</label>
								</div>
							</li>
							{{if !empty($v['item'])}}
								<ul class="list-find am-avg-sm-2 am-avg-md-3 am-avg-lg-4 am-margin-top-xs am-margin-left-xl">
									{{foreach $v.item as $vs}}
										<li>
											<div class="item-content am-padding-sm am-margin-bottom-xs am-margin-right-xs {{if $vs['is_show'] eq 0}}bk-cr-ffd{{/if}}">
											<label>
													<input type="checkbox" name="power_id" value="{{$vs.id}}" {{if $vs['is_power'] eq 'ok'}}checked{{/if}} />
													<span>{{$vs.name}}</span>
												</label>
											</div>
										</li>
									{{/foreach}}
								</ul>
							{{/if}}
						{{/foreach}}
					{{else /}}
						<p class="am-text-warning">无菜单数据</p>
					{{/if}}
				</ul>
			</div>

			<div class="am-form-group">
				<label>插件权限<span class="am-text-warning am-margin-left-sm">插件还需在菜单权限中勾选[ <strong class="am-text-danger">应用中心 -> 应用管理+应用调用管理</strong> ]权限</span></label>
				<ul class="tree-list am-avg-sm-2 am-avg-md-3 am-avg-lg-4">
					{{if !empty($power['plugins'])}}
						{{foreach $power.plugins as $v}}
							<li>
								<div class="item-content am-padding-sm am-margin-bottom-xs am-margin-right-xs">
									<label>
										<input type="checkbox" name="plugins" value="{{$v.plugins}}" class="node-choice" {{if $v['is_power'] eq 'ok'}}checked{{/if}} />
										<span>{{$v.name}}</span>
									</label>
								</div>
							</li>
						{{/foreach}}
					{{else /}}
						<p class="am-text-warning">无插件数据</p>
					{{/if}}
				</ul>
			</div>

			<div class="am-form-group">
			    <label class="block">是否启用</label>
			    <input name="is_enable" value="1" type="checkbox" data-off-text="否" data-on-text="是" data-size="xs" data-on-color="success" data-off-color="default" data-handle-width="50" data-am-switch {{if (isset($data['is_enable']) and $data['is_enable'] eq 1) or !isset($data['is_enable'])}}checked="true"{{/if}} />
			</div>

			<!-- 插件扩展数据 start -->
			{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                <div class="plugins-tag">
                    <span>plugins_view_admin_role_save</span>
                </div>
            {{/if}}
			{{if !empty($plugins_view_admin_role_save_data) and is_array($plugins_view_admin_role_save_data)}}
				<div class="am-alert am-alert-secondary">
					<label class="am-text-sm am-text-warning">该区域为插件扩展数据，请按照插件文档填写相应的值</label>
					<div>
						{{foreach $plugins_view_admin_role_save_data as $hook}}
		                    {{if is_string($hook) or is_int($hook)}}
		                        {{$hook|raw}}
		                    {{/if}}
		                {{/foreach}}
					</div>
				</div>
			{{/if}}
			<!-- 插件扩展数据 end -->

			<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
				<input type="hidden" name="id" {{if !empty($data)}}value="{{$data.id}}"{{/if}} />
				<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
			</div>
		</form>
		<!-- right form end  -->
	</div>
</div>
<!-- right content end  -->
		
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->